// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './vuex/store'

Vue.config.productionTip = false
// 时间
Vue.filter('dateFormat', function (dateTime) {
  var strArr = dateTime.split('.')
  var dateTimeStr = strArr[0]
  var str = dateTimeStr.replace(/-/g, '/')
  var date = new Date(str)
  var time = parseInt(date.getTime() / 1000)
  var curDate = new Date()
  var curTime = parseInt(curDate.getTime() / 1000)
  var returnStr
  console.log(curTime - time)
  if (curTime <= time) {
    returnStr = '刚刚'
  } else if ((curTime - time) <= 1) {
    returnStr = '刚刚'
  } else if ((curTime - time) < 60) { // 几秒前
    returnStr = parseInt(curTime - time) + '秒前'
  } else if ((curTime - time) < 3600) { // 几分钟前
    returnStr = parseInt((curTime - time) / 60) + '分钟前'
  } else if ((curTime - time) < 86400) { // 几小时前
    returnStr = parseInt((curTime - time) / 60 / 24) + '小时前'
  } else {
    returnStr = new Date(parseInt(time) * 1000).toLocaleString()
  }
  return returnStr
})
new Vue({
  router: router,
  store,
  render: h => h(App)
}).$mount('#app')
